// 无机盐状况
import MeasureItem from './MeasureItem'
//import Calc from './Calc'
const UI = require('../style/UI')
const mineralSaltInfo = [
  "您的无机盐当前充足。",
  "您的无机盐当前正常。",
  "您的无机盐当前缺乏。"
];
const BAR = [UI.color.report_lower, UI.color.report_stand, UI.color.report_higher];

export default class MineralSaltReport {

  static getLevelIndex(measure) {
    let bone = measure.bone// / 10;
    let weight = measure.weight;
    if (measure.gender ==1) {
      if (weight <= 60) {
        if (bone < 2.3) {
          return 2;
        } else if (bone >= 2.3 && bone <= 2.7) {
          return 1;
        } else {
          return 0;
        }
      } else if (weight < 75) {
        if (bone < 2.7) {
          return 2;
        } else if (bone >= 2.7 && bone <= 3.1) {
          return 1;
        } else {
          return 0;
        }
      } else {
        if (bone < 2.3) {
          return 2;
        } else if (bone >= 3.0 && bone <= 3.4) {
          return 1;
        } else {
          return 0;
        }
      }
    } else {
      if (weight <= 45) {
        if (bone < 1.6) {
          return 2;
        } else if (bone >= 1.6 && bone <= 2.0) {
          return 1;
        } else {
          return 0;
        }
      } else if (weight < 60) {
        if (bone < 2.0) {
          return 2;
        } else if (bone >= 2.0 && bone <= 2.4) {
          return 1;
        } else {
          return 0;
        }
      } else {
        if (bone < 2.3) {
          return 2;
        } else if (bone >= 2.3 && bone <= 2.7) {
          return 1;
        } else {
          return 0;
        }
      }
    }
  }

  static standShape(index) {
    return index == 1;
  }

  static isEnable(measure) {
    return true
  }

  static build(measure) {
    const value = measure.muscle;
    if (!value || value == 0) {
      return null;
    }

    let index = MineralSaltReport.getLevelIndex(measure);
    const item = new MeasureItem();
    const boundaries = measure.gender == 0 ? [40, 50] : [49, 59];
    const level = index;
    const isStand = MineralSaltReport.standShape(index);

    item.key = 'mineralSalt'
    item.name = "无机盐状况";
    item.boundaries = boundaries;
    item.levelNames = ["充足", "正常", "缺乏"];
    item.showBar = false;
    item.value = item.levelNames[level];
    item.isStand = isStand;
    item.unit = "";
    item.desc = mineralSaltInfo[level];
    item.level = level;
    //item.bar = BAR

    item.min = boundaries[0] - 10;
    item.max = boundaries[1] + 10;
    
    return item
  }

}
